<?php

namespace coreapi\models;

use coreapi\tables\base\Plan;
use coreapi\tables\base\DingcanReturn;
use coreapi\tables\base\GuideReturn;
use coreapi\tables\base\JiaotongReturn;
use coreapi\tables\base\YuleReturn;
use coreapi\tables\base\ZhongzhuanReturn;
use coreapi\tables\base\ZhusuReturn;
use yii\base\Model;


class PlanModel extends Model {

     public static function getZhusuReturn($planid) {
        $result=[];
        $data=  ZhusuReturn::find()->andWhere(['checkstatus'=>3,'planid'=>$planid])->asArray()->all();
        foreach ($data as $key => $value) {
           $map=[];
           if($value['update_date']==null||empty($value['update_date'])){
               $map['date']=date('Y-m-d H:i',strtotime($value['create_date']));
           }else{
              $map['date']=date('Y-m-d H:i',strtotime($value['update_date']));
           }
           $map['checkinfo']=$value['checkinfo'];
           $result[]=$map;
        }

        return $result;
     }

     public static function getZhongzhuanReturn($planid) {

       $result=[];
       $data=  ZhongzhuanReturn::find()->andWhere(['checkstatus'=>3,'planid'=>$planid])->asArray()->all();
       foreach ($data as $key => $value) {
          $map=[];
          if($value['update_date']==null||empty($value['update_date'])){
              $map['date']=date('Y-m-d H:i',strtotime($value['create_date']));
          }else{
             $map['date']=date('Y-m-d H:i',strtotime($value['update_date']));
          }
          $map['checkinfo']=$value['checkinfo'];
          $result[]=$map;
       }

       return $result;

     }

     public static function getJiaotongReturn($planid) {
       $result=[];
       $data=  JiaotongReturn::find()->andWhere(['checkstatus'=>3,'planid'=>$planid])->asArray()->all();
       foreach ($data as $key => $value) {
          $map=[];
          if($value['update_date']==null||empty($value['update_date'])){
              $map['date']=date('Y-m-d H:i',strtotime($value['create_date']));
          }else{
             $map['date']=date('Y-m-d H:i',strtotime($value['update_date']));
          }
          $map['checkinfo']=$value['checkinfo'];
          $result[]=$map;
       }

       return $result;
     }

     public static function getYuleReturn($planid) {

       $result=[];
       $data=  YuleReturn::find()->andWhere(['status'=>3,'planid'=>$planid])->asArray()->all();
       foreach ($data as $key => $value) {
          $map=[];
          if($value['update_time']==null||empty($value['update_time'])){
              $map['date']=date('Y-m-d H:i',strtotime($value['create_time']));
          }else{
             $map['date']=date('Y-m-d H:i',strtotime($value['update_time']));
          }
          $map['checkinfo']=$value['checkinfo'];
          $result[]=$map;
       }

       return $result;

     }

     public static function getGuideReturn($planid) {
       $result=[];
       $data=  GuideReturn::find()->andWhere(['checkstatus'=>3,'planid'=>$planid])->asArray()->all();
       foreach ($data as $key => $value) {
          $map=[];
          if($value['update_date']==null||empty($value['update_date'])){
              $map['date']=date('Y-m-d H:i',strtotime($value['create_date']));
          }else{
             $map['date']=date('Y-m-d H:i',strtotime($value['update_date']));
          }
          $map['checkinfo']=$value['checkinfo'];
          $result[]=$map;
       }

       return $result;
     }

     public static function getDingcanReturn($planid) {
       $result=[];
       $data=  GuideReturn::find()->andWhere(['status'=>3,'planid'=>$planid])->asArray()->all();
       foreach ($data as $key => $value) {
          $map=[];
          if($value['update_date']==null||empty($value['update_date'])){
              $map['date']=date('Y-m-d H:i',strtotime($value['create_date']));
          }else{
             $map['date']=date('Y-m-d H:i',strtotime($value['update_date']));
          }
          $map['checkinfo']=$value['checkinfo'];
          $result[]=$map;
       }

       return $result;
     }

 }
